package me.yushuai.wukong.base.api;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import me.yushuai.wukong.base.api.dto.CreateHsCodeDTO;
import me.yushuai.wukong.base.api.dto.PagingSearchHsCode;
import me.yushuai.wukong.base.api.dto.UpdateHsCodeDTO;
import me.yushuai.wukong.base.api.vo.HsCodeVO;
import me.yushuai.wukong.common.dto.PageDTO;
import me.yushuai.wukong.common.error.WuKongException;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 海关编码管理客户端
 *
 * @author zhoushuai@189.cn
 * @since 2022-08-25
 */
@Api("海关编码API")
@FeignClient("${spring.application.name}")
public interface HsCodeApi {

    /**
     * 新建一条海关编码记录
     *
     * @param createHsCodeDTO 新建海关编码信息
     * @return 返回海关编码的编号
     * @throws WuKongException 当海关编码编码已经存在时抛出异常
     */
    @ApiOperation("新建海关编码")
    @PostMapping("/hs-code")
    Long createHsCode(@Validated @RequestBody CreateHsCodeDTO createHsCodeDTO)
            throws WuKongException;

    /**
     * 修改海关编码信息
     *
     * @param hsCodeId        海关编码编号
     * @param updateHsCodeDTO 海关编码信息
     * @return 返回被修改的海关编码编号
     * @throws WuKongException 当海关编码编号不存在时抛出异常
     */
    @ApiOperation("修改海关编码")
    @PutMapping("/hs-code/{hsCodeId}")
    Long editHsCode(@PathVariable("hsCodeId") Long hsCodeId,
                    @Validated @RequestBody UpdateHsCodeDTO updateHsCodeDTO) throws WuKongException;

    /**
     * 删除一条海关编码信息
     *
     * @param hsCodeId 海关编码编号
     * @return 返回海关编码的编号
     * @throws WuKongException 当海关编码不存在时抛出异常
     */
    @ApiOperation("删除海关编码")
    @DeleteMapping("/hs-code/{hsCodeId}")
    Long deleteHsCode(@PathVariable("hsCodeId") Long hsCodeId) throws WuKongException;

    /**
     * 获取海关编码详细信息
     *
     * @param hsCodeId 海关编码编号
     * @return 返回海关编码详细信息
     * @throws WuKongException 当海关编码信息不存在时抛出异常
     */
    @ApiOperation("海关编码详细信息")
    @GetMapping("/hs-code/{hsCodeId}")
    HsCodeVO getById(@PathVariable("hsCodeId") Long hsCodeId) throws WuKongException;

    /**
     * 分页条件检索海关信息
     *
     * @param searchHsCode 分页检索条件
     * @return 分页返回检索结果
     */
    @ApiOperation("分页条件检索海关编码信息")
    @PostMapping("/hs-code-list")
    PageDTO<HsCodeVO> pagingSearchHsCode(@Validated @RequestBody PagingSearchHsCode searchHsCode);

}
